package com.wp.controller;

import com.wp.pojo.PageResult;
import com.wp.pojo.User;
import com.wp.pojo.UserResult;
import com.wp.pojo.basePojo.SysResult;
import com.wp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    /**
     * 获取用户列表
     * */
    @GetMapping("/getList")
    public SysResult getUserList(PageResult pageResult){
        PageResult pageResults = userService.getUserList(pageResult);
        return SysResult.success(pageResults);
    }
    /**
     * 删除用户
     * */
    @PostMapping("/updateStatus")
    public SysResult updateStatus(@RequestBody UserResult userResult){
        userService.deleteUser(userResult);
        return SysResult.success();
    }
    /**
     * 重置密码
     */
    @PostMapping("/resetUserPassword")
    public SysResult resetUserPassword(@RequestBody User user){
       String token = userService.resetUserPassword(user);
        return SysResult.success(token);
    }
    /**
     * 更新用户禁言状态
     * */
    @PostMapping("/updateCommentStatus")
    public SysResult updateCommentStatus (@RequestBody User user){
        return SysResult.success(userService.updateCommentStatus(user));
    }
}
